package br.com.reparoja.reparoja.ui;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;

import java.util.Arrays;

import br.com.reparoja.reparoja.MainActivityDrawer;
import br.com.reparoja.reparoja.R;
import br.com.reparoja.reparoja.adapter.DrawerAdapter;

public class DrawerFragment extends Fragment implements ListView.OnItemClickListener {

    private ListView drawerList;
    private MainActivityDrawer mainActivity;

    public DrawerFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        this.mainActivity = (MainActivityDrawer) getActivity();

        if (getArguments() != null) {
            //mParam1 = getArguments().getString(ARG_PARAM1);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_drawer, container, false);

        this.drawerList = (ListView) view.findViewById(R.id.items);
        DrawerAdapter adapter = new DrawerAdapter(mainActivity, (String[]) Arrays.asList("Avaliar", "Configuracoes").toArray());
        drawerList.setAdapter(adapter);
        drawerList.setOnItemClickListener(this);

        return view;
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        this.mainActivity.onDrawerItemClicked(position, this.drawerList);
    }







}
